<script setup>
import { defineProps,defineEmits} from 'vue'
const props = defineProps({
  money:{
    type:Number,
    required:true,
    default:200
  },
  books:Array,
  msg:String,
  user:Object
})

const emits = defineEmits(['buy']);

function changeData(){
  emits('buy',5);
}


</script>

<template>
  <h2>我是子组件</h2>
  <!-- 展示拿到的数据 -->
  <li v-for="book in books">
    {{book}}
  </li>
  <h3>一共多少钱：{{money}}</h3>
  <p>{{msg}}</p>
  <p>{{user.username}}</p>
  <p>{{user.age}}</p>
  
  <button @click="changeData">给父组件传递数据</button>
</template>

<style scoped>

</style>